<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>宣传任务</title>
		<!-- 导入jquery核心类库 -->
		<script type="text/javascript" src="../../js/jquery-1.8.3.js"></script>
		<!-- 导入easyui类库 -->
		<link rel="stylesheet" type="text/css" href="../../js/easyui/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../js/easyui/themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../js/easyui/ext/portal.css">
		<link rel="stylesheet" type="text/css" href="../../css/default.css">
		<script type="text/javascript" src="../../js/easyui/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../../js/easyui/ext/jquery.portal.js"></script>
		<script type="text/javascript" src="../../js/easyui/ext/jquery.cookie.js"></script>
		<script src="../../js/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
		<!--引入在线HTML编辑器-->
		<script type="text/javascript" src="../../editor/kindeditor.js"></script>
		<script type="text/javascript" src="../../editor/lang/zh_CN.js"> </script>
		<link rel="stylesheet" href="../../editor/themes/default/default.css">
		<script type="text/javascript">
				// 宣传任务表格			
			$(function () {
                KindEditor.ready(function (K) {
                    window.editor = K.create('#description',{
                        allowFileManager:true,
                        uploadJson:'../../image_upload',
                        fileManagerJson:'../../image_manager'
                    });
                });
                //为保存按钮提供事件

                $("#save").click(function () {
                    if($("#promotionForm").form('validate')){

                        window.editor.sync();
                        $("#promotionForm").submit();
                    }else{
                        $.messager.alert("警告","表单中存在非法数据!","warning");
                    }
                });

                $("#grid").datagrid({
                    url:"../../promotion_pageQuery",
                    columns: [
                        [{
                            field: 'id',
                            title: '编号',
                            width: 100,
                            checkbox: true
                        }, {
                            field: 'title',
                            title: '宣传概要（标题）',
                            width: 200
                        }, {
                            field: 'titleImg',
                            title: '宣传图片',
                            width: 200,
                            formatter:function (value,row,index) {
                                return "<image src='"+value+"'width='100'height='100'/>";
                            }
                        },{
                            field: 'startDate',
                            title: '发布时间',
                            width: 100,
                            formatter: function (value,row,index) {
                                return value.replace("T"," ")
                            }
                        }, {
                            field: 'endDate',
                            title: '失效时间',
                            width: 100,
                            formatter: function (value,row,index) {
                                return value.replace("T"," ")
                            }

                        }, {
                            field: 'updateTime',
                            title: '更新时间',
                            width: 100
                        }, {
                            field: 'updateUnit',
                            title: '更新单位',
                            width: 100
                        }, {
                            field: 'updateUser',
                            title: '更新人',
                            width: 100
                        }, {
                            field: 'status',
                            title: '状态',
                            width: 100,
                            formatter:function (value,row,index) {
                                if(value==1){
                                    return "进行中";
                                }else{
                                    return"已结束";
                                }

                            }
                        }]
                    ],
                    pagination: true,
                    toolbar: [{
                        id: 'searchBtn',
                        text: '查询',
                        iconCls: 'icon-search'
                    }, {
                        id: 'addBtn',
                        text: '增加',
                        iconCls: 'icon-add',
                        handler: function () {
                            $('#addWindow').window("open");
                        }
                    }, {
                        id: 'editBtn',
                        text: '修改',
                        iconCls: 'icon-edit',
                        handler: function() {
                            var rows =$("#grid").datagrid('getSelections');
                            if(rows.length!=1){
                                $.messager.alert("警告","一次只能修改一条数据","warning");
                            }else{
                                //让数据回显
                                var row = rows[0];
                                $("#promotionForm").form('load',row);
                                $("#addWindow").window('open');

                            }

                        }
                    }, {
                        id: 'deleteBtn',
                        text: '作废',
                        iconCls: 'icon-cancel',
                        handler: function() {
                            alert('作废');
                        }
                    },{
                        id: 'saveBtn',
                        text: '保存',
                        iconCls: 'icon-save',
                        handler: function() {
                            alert('保存成功');
                        }
                    },
                        {
                            id: 'cancelBtn',
                            text: '取消',
                            iconCls: 'icon-no',
                            handler: function() {
                                alert('取消宣传任务');
                            }
                        }

                    ]
                });
                // 添加、修改区域窗口
                $('#addWindow').window({
                    title: '添加修改区域',
                    width: 800,
                    modal: true,
                    shadow: true,
                    closed: true,
                    height: 800,
                    resizable:false
                });
            });

		</script>
	</head>

	<body class="easyui-layout">
		<div region="center" style="overflow:auto;padding:5px;">
			<table id="grid"></table>
		</div>
		<div class="easyui-window" title="区域添加修改" id="addWindow" collapsible="false" minimizable="false" maximizable="false" style="top:20px;left:200px">
			<div region="north" style="height:31px;overflow:hidden;" split="false" border="false">
				<div class="datagrid-toolbar">
					<a id="save" icon="icon-save" href="#" class="easyui-linkbutton" plain="true" onclick="saveArea()">保存</a>
				</div>
			</div>

			<div region="center" style="overflow:auto;padding:5px;" border="false">
				<form id="promotionForm" method="post" action="../../save_promotion" enctype="multipart/form-data">
					<table class="table-edit" width="95%" align="center">
						<tr class="title">
							<td colspan="4">宣传任务</td>

						</tr>
						<input type="hidden" name="id">
						<tr>
							<td>宣传概要(标题):</td>
							<td colspan="3">
								<input type="text"  name="title" id="title"  class="easyui-validatebox" required="true" />
							</td>
						</tr>
						<tr>
							<td>活动范围:</td>
							<td>
								<input type="text" name="activeScope"  id="activeScope" class="easyui-validatebox" />
							</td>
							<td>宣传图片:</td>
							<td>
								<input type="file" name="titleImgFile"  id="titleImg" class="easyui-validatebox" required="true"/>
							</td>
						</tr>
						<tr>
							<td>发布时间: </td>
							<td>
								<input type="text" name="startDate"  id="startDate" class="easyui-datebox" required="true" />
							</td>
							<td>失效时间: </td>
							<td>
								<input type="text" name="endDate" id="endDate"  class="easyui-datebox" required="true" />
							</td>
						</tr>
						<tr>
							<td>宣传内容(活动描述信息):</td>
							<td colspan="3">
								<textarea name="description" id="description"  style="width:80%" rows="20"></textarea>
							</td>
						</tr>
					</table>
				</form>
			</div>
		</div>



	</body>

</html>